Skip to content

feat(token): add p-token (SIMD-0266) and missing SPL Token instructions#366

Open
hxuan190 wants to merge 1 commit intosolana-foundation:mainfrom
hxuan190:feat/ptoken-instructions
Open

feat(token): add p-token (SIMD-0266) and missing SPL Token instructions#366
hxuan190 wants to merge 1 commit intosolana-foundation:mainfrom
hxuan190:feat/ptoken-instructions

Conversation

@hxuan190
Copy link
Copy Markdown

Add support for 7 missing token instructions to the SPL Token program:

Instructions 21-24 (existing on-chain, missing from solana-go):

  • GetAccountDataSize (ID 21)
  • InitializeImmutableOwner (ID 22)
  • AmountToUiAmount (ID 23)
  • UiAmountToAmount (ID 24)

P-token exclusive instructions (SIMD-0266 / Pinocchio):

  • WithdrawExcessLamports (ID 38)
  • UnwrapLamports (ID 45)
  • Batch (ID 255)

Updated instructions.go with new constants, InstructionIDToName entries, extended InstructionImplDef for IDs 0-24, and added pTokenInstructionMap with custom DecodeInstruction dispatch for non-contiguous p-token IDs.

Verified on Solana testnet (SIMD-0266 feature gate activated at slot 396236256, address ptokFjwyJtrwCa9Kgo9xoDS59V4QccBGEaRFnRPnSdP):

Simulation tests (IDs 20-24):

  • InitializeMint2: 364 CUs
  • GetAccountDataSize: 179 CUs
  • AmountToUiAmount: 615 CUs
  • UiAmountToAmount: 589 CUs

Send+confirm tests (p-token exclusive):

  • WithdrawExcessLamports (ID 38): 3C9iNnUPPaqRCA1RSD5tXDpD7ZW72VQYsKYm1j3voEYcH4UCfzKURan63Df2jdfX3gzPzEHZDu6eFfnTf2K4H98d
  • UnwrapLamports partial (ID 45): zPrV9K6wLqnES4RBDAQs15S8MgvC48QjsLZAmPoimvY6vmQkh8yi3XBJYqQBkpo28HpiNdhuPL3N65Dqf1ovhWn
  • UnwrapLamports all (ID 45): 5VVDC6PeWo5sAAUhbc3xRRiZDMo1t5Y6c1VDktBqLLhXZtri1HshL9y7TmEu9BBZEpiQCdAmULazfNjTfeHd5ujH
  • Batch with 2 transfers (ID 255): 2y1jC5rXbQvvym1bM5ukRcQfiovUQPi4fbcryixXpjTe5fc2UDGvvgurZqLNx7DEYd7NHHwEnEt6oPX4anV9kXnh

Add support for 7 missing token instructions to the SPL Token program:

Instructions 21-24 (existing on-chain, missing from solana-go):
- GetAccountDataSize (ID 21)
- InitializeImmutableOwner (ID 22)
- AmountToUiAmount (ID 23)
- UiAmountToAmount (ID 24)

P-token exclusive instructions (SIMD-0266 / Pinocchio):
- WithdrawExcessLamports (ID 38)
- UnwrapLamports (ID 45)
- Batch (ID 255)

Updated instructions.go with new constants, InstructionIDToName entries,
extended InstructionImplDef for IDs 0-24, and added pTokenInstructionMap
with custom DecodeInstruction dispatch for non-contiguous p-token IDs.

Verified on Solana testnet (SIMD-0266 feature gate activated at slot
396236256, address ptokFjwyJtrwCa9Kgo9xoDS59V4QccBGEaRFnRPnSdP):

Simulation tests (IDs 20-24):
- InitializeMint2: 364 CUs
- GetAccountDataSize: 179 CUs
- AmountToUiAmount: 615 CUs
- UiAmountToAmount: 589 CUs

Send+confirm tests (p-token exclusive):
- WithdrawExcessLamports (ID 38):
  3C9iNnUPPaqRCA1RSD5tXDpD7ZW72VQYsKYm1j3voEYcH4UCfzKURan63Df2jdfX3gzPzEHZDu6eFfnTf2K4H98d
- UnwrapLamports partial (ID 45):
  zPrV9K6wLqnES4RBDAQs15S8MgvC48QjsLZAmPoimvY6vmQkh8yi3XBJYqQBkpo28HpiNdhuPL3N65Dqf1ovhWn
- UnwrapLamports all (ID 45):
  5VVDC6PeWo5sAAUhbc3xRRiZDMo1t5Y6c1VDktBqLLhXZtri1HshL9y7TmEu9BBZEpiQCdAmULazfNjTfeHd5ujH
- Batch with 2 transfers (ID 255):
  2y1jC5rXbQvvym1bM5ukRcQfiovUQPi4fbcryixXpjTe5fc2UDGvvgurZqLNx7DEYd7NHHwEnEt6oPX4anV9kXnh

All 68 tests pass (30 existing + 38 new), zero regressions.

Made-with: Cursor
@hxuan190 hxuan190 marked this pull request as draft March 23, 2026 19:49
@hxuan190 hxuan190 marked this pull request as ready for review March 23, 2026 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant